<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_search
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;
$id = 1;
$db = JFactory::getDbo();
$q = "SELECT * FROM ".$db->quoteName('#__country_list')." WHERE id <> ''";
$db->setQuery($q);
$country_list = $db->loadObjectList();
//var_dump($countries);die;
?>
<form id="member-registration" action="<?php echo JRoute::_('index.php?option=com_users&task=registration.register'); ?>" method="post">
	<div class="input-block ip-col-2">
		 <input name="name" id="name" type="text" class="f-input i-toggle" value="Name *">
	</div>
	<div class="input-block ip-col-2 col-last">
	  <input name="company" id="company" type="text" class="f-input i-toggle" value="Company *">
	</div>
	<div class="input-block ip-col-2">
		<input name="email" id="email" type="text" class="f-input i-toggle" value="E-mail *">
	</div>
	<div class="input-block ip-col-2 col-last">
	    <select class="f-select" name="country" id="country">
			<?php foreach($country_list as $country):?>
			<option value="<?php echo $country->id;?>" <?php echo $country->name=='Denmark'?'selected':'';?>><?php echo $country->name;?></option>
			<?php endforeach;?>
		</select>
	</div>
	<div class="clear"></div>
	<div class="clr"></div>
	<div class="form-submit clearfix">
		<a href="javascript:void(0)" onclick="jQuery('#member-registration').submit();" class="btnSubmit fll">Send</a>
		<p id="p-field2">* All fields are mandatory</p>
	</div>
	<input type="hidden" name="option" value="com_users" />
	<input type="hidden" name="task" value="registration.register" />
	<input type="hidden" name="groupid" value="9" />
	<?php echo JHtml::_('form.token');?>
</form>
               
 <?php                        	       
$input_name = JText::_( 'Please Enter Your Name' );
$input_fname = JText::_( 'Please Enter Your First Name' );
$input_lname = JText::_( 'Please Enter Your Last Name' );
$input_title = JText::_( 'Please Enter Your Title' );
$input_company = JText::_( 'Please Enter Your Company' );
$input_phone = JText::_( 'Please Enter Your Phone' );
$input_email = JText::_( 'Please Enter Your Email' );
$input_country = JText::_( 'Please Enter Your Country' );
$input_industry = JText::_( 'Please Enter Your Industry' );
$input_node = JText::_( 'Please Enter Your Estimated nodes' );
$input_message = JText::_( 'Please Enter Your Message' );

	
?>                        
 <script type="text/javascript">                   
jQuery(document).ready(function(jQuery) {
	jQuery.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		return /^\d{4}$/.test(value); 
	   }, '');
	jQuery.validator.addMethod("notEqual", function(value, element, param) {
			return this.optional(element) || value !== param;
	});
		//jQuery("#postcode").mask("9999",{placeholder:""});  
		jQuery('#member-registration').validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
                //$('#alert').html(validator['errorList'][0]['message']);
				jQuery('#alert').html(validator['errorList'][0]['message']);
    			jQuery('#backoverlay').show();
    			jQuery('#show_popup').show();
            	jQuery('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				
			  } else {
			  }
			},
			rules: {
				name:{
					required: true,
					notEqual: "Name *",
				},
				
				
				company:{
					required: true,
					notEqual: "Company *",
				},	
				email:{
					required: true,
					email: true,
					notEqual: "...",
				},	
				
				country:{
					required: true,
					notEqual: "...",
				},
				
			},
			messages: {
				name: "<?php echo $input_name; ?>",
				company: "<?php echo $input_company; ?>",
				email: "<?php echo $input_email; ?>",
				country: "<?php echo $input_country; ?>",
			
			}
		});
        close_popup=function(){		
			var fel=jQuery('#f_focus').html();
            jQuery('#backoverlay').hide();
    		jQuery('#show_popup').hide();
    		jQuery('#' + fel ).focus();		
      };
      
      
	});
</script>


